//
// Created by 刘禹晨 on 16/7/26.
// Copyright (c) 2016 yuchenliu. All rights reserved.
//

#import "AboutController.h"
#import <SDAutoLayout/SDAutoLayout.h>
#import "ViewController.h"

#define kW [UIScreen mainScreen].bounds.size.width
#define kH [UIScreen mainScreen].bounds.size.height

@interface AboutController()

{
    UILabel *aboutLabel;
    UIImageView *logoImage;
    ViewController *mainVC;
}

@end


@implementation AboutController

-(void)viewDidLoad
{
    [super viewDidLoad];
    if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
        self.navigationController.interactivePopGestureRecognizer.enabled = NO;
    }
    self.navigationItem.title = @"关于";
    UIBarButtonItem *backButton = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"back"] style: UIBarButtonItemStylePlain target:self action:@selector(backToViewController:)];
    self.navigationItem.leftBarButtonItem = backButton;
    [self.view setBackgroundColor:[UIColor whiteColor]];
    [self initLogoImage];
    [self initAboutLabel];
}

-(void)initLogoImage
{
    logoImage = [[UIImageView alloc]init];
    [logoImage setImage:[UIImage imageNamed:@"logo_icon"]];
    logoImage.contentMode = UIViewContentModeScaleAspectFit;
    [self.view addSubview:logoImage];
    
    logoImage.sd_layout.widthIs(kW/1.2).heightIs(kH/2.5).topSpaceToView(self.view,kH/12).centerXEqualToView(self.view);
}


-(void)initAboutLabel
{
    aboutLabel = [[UILabel alloc]init];
    aboutLabel.numberOfLines = 0;//上面两行设置多行显示
    aboutLabel.textAlignment = NSTextAlignmentCenter;
    aboutLabel.text = @"创智翔宇\n便携式安防系统客户端\n\n版本  V1.0";
    [self.view addSubview:aboutLabel];
    
    aboutLabel.sd_layout.widthIs(kW).heightRatioToView(logoImage,0.6).topSpaceToView(logoImage,8);
}

-(void)backToViewController:(id)sender
{
    if(mainVC == nil){
        mainVC = [self.navigationController.viewControllers objectAtIndex:0];
    }
    [self.navigationController popToViewController:mainVC animated:YES];
    [mainVC viewDidAppear:YES];
}



@end